package com.example.rbacmanage.service.app.impl;

import com.example.rbacmanage.entity.app.Photo;
import com.example.rbacmanage.mapper.app.PhotoMapper;
import com.example.rbacmanage.service.app.PhotoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PhotoServiceImpl implements PhotoService {
    @Autowired
    private PhotoMapper photoMapper;
    @Override
    public void save(Photo photo) {
        photoMapper.insert(photo);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id : ids) {
            photoMapper.del(id);
        }
    }

    @Override
    public void update(Photo photo) {
        photoMapper.update(photo);
    }

    @Override
    public List<Photo> getAll(Photo photo) {
        return photoMapper.list(photo);
    }

    @Override
    public PageInfo<Photo> getPage(Photo photo) {
        PageHelper.startPage(photo.getPage(),photo.getLimit());
        return new PageInfo<>(getAll(photo));
    }

    @Override
    public Photo getById(Long id) {
        return photoMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(Photo photo) {
        return photoMapper.count(photo);
    }
}
